package com.aaa.dao;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

public interface F_YuanGongDao {
    @Select("<script>select a.* ,b.name rolename,c.manage from emp a LEFT JOIN role b on a.roleid=b.rid LEFT JOIN manage_unit c on a.deptid=c.id" +
            " where 1=1 and a.state2=1<if test=\"id!=null and id!=0\"> and a.id = #{id}</if>" +
            " <if test=\"ename!=null and ename!=''\"> and ename like concat('%',#{ename},'%')</if>"+
            "limit #{start},#{pageSize}</script>")
    List<Map> selectList(Map map);
    @Select("<script>select count(id) from emp" +
            " where 1=1 and state2=1<if test=\"id!=null and id!=0\"> and id = #{id}</if>" +
            " <if test=\"ename!=null and ename!=''\"> and ename like concat('%',#{ename},'%')</if> </script>")
    Integer getCount(Map map);
  @Delete("DELETE FROM emp where id=#{id}")
    int delEmp(Integer id);
@Insert("INSERT into emp(ename,telephone,dizhi,state,username,password,roleid,state2,deptid) VALUES(#{ename},#{telephone},#{dizhi},#{state},#{username},#{password1},#{x},1,#{id})")
    int add(Map map);
@Update("update emp set ename=#{ename},telephone=#{telephone},dizhi=#{dizhi},state=#{state},username=#{username},password=#{password1},roleid=#{x},deptid=#{manage2} where id=#{id}")
    int update(Map map);
    @Select("select rid,name from role")
    List<Map> getRole();
@Select("select rid from role where name=#{rolename}")
    int getid(Map map);
@Select("select id,manage from manage_unit")
    List<Map> getShi();
@Select("select id from manage_unit where manage=#{s2}")
    int getManage(String s2);
}
